package com.hs.app.action.stat;
 
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

import com.hs.app.helper.ChangeCharset;
import com.hs.app.service.IDataService;
import com.hs.core.action.BaseAction;
import com.hs.core.db.DBMgr;
@Controller   
public class StatController  extends BaseAction {
    private static final Logger logger = Logger.getLogger(StatController.class);
	private IDataService dataService;
	@Autowired  
	public void setDataService(IDataService dataService) {
		this.dataService = dataService;
	}
	/**
	  * 统计分析主页
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/stat/statindex.do")   
   public ModelAndView statindex(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 String pidstr = request.getParameter("pidstr");
//		 String searchtype = request.getParameter("searchtype");
//		 String qstr = request.getQueryString();
//		 Map parammap = null;
//		 if("basic_search".equals(searchtype)){
//			 parammap = basicSearchPrepare(request);
//		 }else if("advsearch".equals(searchtype)) {
//			 parammap = this.advSearchPrepare(request);
//		 }
//		 StringBuffer allfullsql = (StringBuffer)parammap.get("allfullsql");//request.getParameter("allsql"); 
//		 String rangesql = allfullsql.toString();
//		 if(null != rangesql && rangesql.indexOf("order by")!=-1){
//			 rangesql = rangesql.substring(0,rangesql.indexOf("order by"));
//		 }
//		 //String allsql = "select * from TCM_CLINIC_JMZ_YFLF where  ZLGC_ID in(select a.JTZLGC_ID from TCM_CLINIC_JMZ_JTZLGC a,(select LCYJ_ID from SCHD_PAPER_RELATION where pid in(select id from " + rangesql + ")) b where a.LCYJ_ID=b.LCYJ_ID ) ";
//		 String allsql = "SELECT * FROM (select fjmc,count(*) as countnum from (select yfmc as fjmc from SCHD_TCM_CLINIC_C_YFLF where yw_id in (select d.LCYJ_ID from  ("+rangesql+") c,SCHD_PAPER_RELATION d where c.id=d.pid )) group by fjmc order by count(*) desc) WHERE ROWNUM<=100";
//		 DBMgr dbo = DBMgr.getDbUtilInst(request.getSession().getServletContext());
//		 List datalist = dbo.queryList(allsql, null);
//		 modelMap.put("datalist", datalist);
//		 modelMap.put("allsql", rangesql);
//		 System.out.println("sql:" + rangesql);
//		 modelMap.put("searchtype", searchtype);
		 if(null == pidstr)
			 pidstr = "";
		 modelMap.put("pidstr", pidstr);
 		 return new ModelAndView("app/stat/statindex",modelMap);
		 
  } 
	 /**
	  * 统计分析主页
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/stat/stattree.do")   
	   public ModelAndView stattree(HttpServletRequest request,
					HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 
		    StringBuilder builder = new StringBuilder(); 
			 
			DBMgr dbutil = this.getDbo(request);  
			List alldataList = dbutil.queryList("select * from CDC_TAGS where ISDELETE=1   order by ORDERNUM", null);
			logger.debug("alldataList:" + alldataList);
			for(int i=0;i<alldataList.size();i++){
				
				Map tag  = (Map)alldataList.get(i);
				logger.debug("map:" + tag);
				String codename = (String)tag.get("TAGNAME"); 
				String dictcode =  tag.get("ID") + "";
				String pid =  tag.get("PID") + "";
		 
					builder.append("{ id:");
					builder.append(dictcode);
					builder.append(", pId:");
					builder.append(pid);
					builder.append(", name:\"");
					builder.append(codename);
					builder.append("\"");
					if(Integer.parseInt(dictcode) <=3){
						builder.append(",chkDisabled:true"); 
					}
					builder.append("}");
					if(i != alldataList.size() - 1){
						builder.append(",");
					}
					builder.append("\n");  
				
			}
			modelMap.put("treedata", builder.toString());
	 		return new ModelAndView("app/stat/stattree",modelMap);
			 
	  } 
	 /**
	  * 统计分析二级页面
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/stat/statview.do")   
     public ModelAndView statview(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 String pidstr = request.getParameter("pidstr");
		 
		 StringBuffer idstr = new StringBuffer("");
		 if(StringUtils.isNotEmpty(pidstr)){
			 List datalist = this.getDbo(request).queryList("select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+"))", null);
			 for(int i =0;i<datalist.size();i++){
				 Map data = (Map)datalist.get(i);
				 String pid = data.get("PID")+"";
				 idstr.append(pid);
				 if(i != (datalist.size() -1)){
					 idstr.append(",");
				 }
			 }
		 }
		 modelMap.put("pidstr", idstr);
		 return new ModelAndView("app/stat/statframe",modelMap);
	 }
	 
	/** 跳转中转*/
	 private static final Map<String,String> redirect = new HashMap<String, String>();
	 static{
		 redirect.put("11", "statlist.do");
		 redirect.put("21", "statyjff.do");
		 redirect.put("31", "statlcYjyy.do");
		 redirect.put("41", "statlcZljb.do");
		 redirect.put("51", "statlcZdbz.do");
		 redirect.put("61", "statlcLxbj.do");
		 redirect.put("71", "statlcDzzs.do");
		 redirect.put("81", "statlcLxzb.do");
		 
		 redirect.put("12", "statylYlzylx.do");
		 redirect.put("22", "statylYlzy.do");
		 redirect.put("32", "statylSydx.do");
		 redirect.put("42", "statylSydxlx.do");
		 redirect.put("52", "statylSyfflx.do");
		 redirect.put("62", "statylSyffmc.do");
		 redirect.put("72", "statylLxzb.do");
		 
		 redirect.put("13", "stathxHxcflx.do");
		 redirect.put("23", "stathxHxcfmc.do");
		 redirect.put("33", "stathxFlff.do");
		 redirect.put("43", "stathxTcff.do");
		 redirect.put("53", "stathxHxcfcdff.do");
		 redirect.put("63", "stathxDxcw.do");
		 redirect.put("73", "stathxHxcfhl.do");
		 
		 redirect.put("14", "stataqBlfylx.do");
		 redirect.put("24", "stataqBlfybx.do");
		 redirect.put("34", "stataqZlbz.do");
		 redirect.put("44", "stataqBlfyfl.do");
		 redirect.put("54", "stataqBlfycsyy.do");
	 }
	 
	 /**
	  * 统计首页点击
	 * @param request
	 * @param response
	 * @param modelMap
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/statDitribute.do") 
	public ModelAndView statDitribute(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String type = request.getParameter("type");
		String moduleid = request.getParameter("moduleid");
		String pidstr = request.getParameter("pidstr");
		return new ModelAndView(new RedirectView(redirect.get(moduleid+type)+"?type="+type+"&pidstr="+pidstr)); 
	 }
	 
	 
	 /****************************************临床统计****************************************************/
	 /**
	  * 临床信息
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/stat/statone.do")   
     public void statone(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
 		 //研究例数(加载中...) 研究方法(加载中...) 研究医院(加载中...) 治疗疾病(加载中...) 诊断标准(加载中...) 
		 //疗效标准(加载中...) 是否联合用药(加载中...) 对照组数(加载中...) 疗效指标(加载中...)
		 StringBuffer returnbuffer = new StringBuffer();
		 String pidstr = request.getParameter("pidstr");
 		 StringBuffer yanjiuls = new StringBuffer("SELECT SUM(YANJIUCOUNT) FROM CDC_LINCHUANG WHERE 1=1  ");
 		 StringBuffer yanjiuff = new StringBuffer("SELECT distinct YANJFF FROM CDC_LINCHUANG WHERE 1=1  ");
 		 StringBuffer yanjiuyy = new StringBuffer("SELECT distinct YANJIUYY FROM CDC_LINCHUANG WHERE 1=1  ");
 		 StringBuffer zhiliaojb = new StringBuffer("SELECT distinct ZHILJB FROM CDC_LINCHUANG WHERE 1=1  ");
 		 StringBuffer zhenduanbz = new StringBuffer("SELECT distinct ZDBZ FROM CDC_LINCHUANG WHERE 1=1  ");
 		 StringBuffer liaoxiaobz = new StringBuffer("SELECT distinct LXBZ  FROM CDC_LINCHUANG WHERE 1=1  ");
 		 StringBuffer duizhaozs = new StringBuffer("SELECT count(*) FROM CDC_LINCDZ WHERE 1=1  ");
 		 StringBuffer liaoxiaozb = new StringBuffer("SELECT count(*) FROM CDC_LXZB WHERE rtype=2  ");

		 if(StringUtils.isNotEmpty(pidstr)){
			 yanjiuls.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 yanjiuff.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 yanjiuyy.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 zhiliaojb.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 zhenduanbz.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 liaoxiaobz.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 duizhaozs.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 liaoxiaozb.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");

		 }
		 DBMgr dbo = this.getDbo(request);
		 int yanjiulsh = dbo.queryCountForInt(yanjiuls.toString(), null);
		 int yjff = dbo.queryCountForInt("select count(*) from ("+yanjiuff.toString()+")", null);
		 int yjyy = dbo.queryCountForInt("select count(*) from ("+yanjiuyy.toString()+")", null);
		 int zljb = dbo.queryCountForInt("select count(*) from ("+zhiliaojb.toString()+")", null);
		 int zdbz = dbo.queryCountForInt("select count(*) from ("+zhenduanbz.toString()+")", null);
		 int lxbz = dbo.queryCountForInt("select count(*) from ("+liaoxiaobz.toString()+")", null); 
		 int dzzs = dbo.queryCountForInt(duizhaozs.toString(), null);
		 int lxzb = dbo.queryCountForInt(liaoxiaozb.toString(), null);
		 
		 returnbuffer.append("m_1_1#").append(yanjiulsh).append(",");
		 returnbuffer.append("m_1_2#").append(yjff).append(",");
		 returnbuffer.append("m_1_3#").append(yjyy).append(",");
		 returnbuffer.append("m_1_4#").append(zljb).append(",");
		 returnbuffer.append("m_1_5#").append(zdbz).append(",");
		 returnbuffer.append("m_1_6#").append(lxbz).append(",");
		 returnbuffer.append("m_1_7#").append(dzzs).append(",");
		 returnbuffer.append("m_1_8#").append(lxzb);
		 PrintWriter out = response.getWriter();
	     out.print(returnbuffer.toString());
	     out.flush();
	     out.close();
	 }
	 
	 /**
	  * 临床研究例数统计
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/stat/statlist.do")   
     public ModelAndView statlist(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 String pidstr = request.getParameter("pidstr");
		 String type = request.getParameter("type");
		 
		 DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT SUM(YANJIUCOUNT) as count,pid,(select title from CDC_BIBLIO where id=pid) as title FROM CDC_LINCHUANG ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by pid) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
		 return new ModelAndView("app/stat/stat_lc_numbers",modelMap);
	 }
	 
	 /**
	  * 临床研究方法统计
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/stat/statyjff.do")   
     public ModelAndView statyjff(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 String pidstr = request.getParameter("pidstr");
		 DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  YANJFF,count(*) as count FROM CDC_LINCHUANG   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by YANJFF) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
		 return new ModelAndView("app/stat/stat_lc_research",modelMap);
	 }
	 
	 /**
	  * 临床信息：文献列表
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/stat/paperlistone.do")   
     public ModelAndView paperlistone(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 String mid = request.getParameter("mid");
		 String paramvalue = request.getParameter("paramvalue");
		 DBMgr dbo = this.getDbo(request);
		 String tempsql = "";
		 if("2".equals(mid)){
			 tempsql = "SELECT   b.title,b.author,b.PERIODICALNAME,b.id as pid   FROM CDC_LINCHUANG a,CDC_BIBLIO b   where A.PID = b.id and "+
		               " a.YANJFF='"+paramvalue+"'";
			 
		 }else if("3".equals(mid)){
			 tempsql = "SELECT   b.title,b.author,b.PERIODICALNAME,b.id as pid   FROM CDC_LINCHUANG a,CDC_BIBLIO b   where A.PID = b.id and "+
		               " a.YANJIUYY='"+paramvalue+"'";
		 }else if("4".equals(mid)){
			 tempsql = "SELECT   b.title,b.author,b.PERIODICALNAME,b.id as pid   FROM CDC_LINCHUANG a,CDC_BIBLIO b   where A.PID = b.id and "+
		               " a.ZHILJB='"+paramvalue+"'";
			 
		 }else if("5".equals(mid)){
			 tempsql = "SELECT   b.title,b.author,b.PERIODICALNAME,b.id as pid   FROM CDC_LINCHUANG a,CDC_BIBLIO b   where A.PID = b.id and "+
		               " a.ZDBZ='"+paramvalue+"'";
			 
		 }else if("6".equals(mid)){
			 tempsql = "SELECT   b.title,b.author,b.PERIODICALNAME,b.id as pid   FROM CDC_LINCHUANG a,CDC_BIBLIO b   where A.PID = b.id and "+
		               " a.LXBZ='"+paramvalue+"'";
		 } 
		 
		 List datalist = dbo.queryList(tempsql, null); 
		 modelMap.put("datalist", datalist);
		 return new ModelAndView("app/stat/paperlist",modelMap);
	 }
	 /**
	  * 药理信息：文献列表
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/stat/paperlisttwo.do")   
     public ModelAndView paperlisttwo(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 String mid = request.getParameter("mid");
		 String paramvalue = request.getParameter("paramvalue");
		 DBMgr dbo = this.getDbo(request);
		 String tempsql = "";
		 if("1".equals(mid)){
			 tempsql = "SELECT   b.title,b.author,b.PERIODICALNAME,b.id as pid   FROM CDC_FJ_ZY_ZF_YLZY a,CDC_BIBLIO b   where A.PID = b.id and "+
		               " a.YLZYLX='"+paramvalue+"'";
		 }else if("2".equals(mid)){
			 tempsql = "SELECT   b.title,b.author,b.PERIODICALNAME,b.id as pid   FROM CDC_FJ_ZY_ZF_YLZY a,CDC_BIBLIO b   where A.PID = b.id and "+
		               " a.YLZY='"+paramvalue+"'";
			 
		 }else if("3".equals(mid)){
			 tempsql = "SELECT   b.title,b.author,b.PERIODICALNAME,b.id as pid   FROM CDC_SYQK a,CDC_BIBLIO b   where A.PID = b.id and "+
		               " a.SYDX='"+paramvalue+"'";
		 }else if("4".equals(mid)){
			 tempsql = "SELECT   b.title,b.author,b.PERIODICALNAME,b.id as pid   FROM CDC_SYQK a,CDC_BIBLIO b   where A.PID = b.id and "+
		               " a.SYDXLX='"+paramvalue+"'";
			 
		 }else if("5".equals(mid)){
			 tempsql = "SELECT   b.title,b.author,b.PERIODICALNAME,b.id as pid   FROM CDC_JSFF a,CDC_BIBLIO b   where A.PID = b.id and "+
		               " a.SYFFLX='"+paramvalue+"'";
			 
		 }else if("6".equals(mid)){
			 tempsql = "SELECT   b.title,b.author,b.PERIODICALNAME,b.id as pid   FROM CDC_JSFF a,CDC_BIBLIO b   where A.PID = b.id and "+
		               " a.SYFFMC='"+paramvalue+"'";
		 } 
		 
		 List datalist = dbo.queryList(tempsql, null); 
		 modelMap.put("datalist", datalist);
		 return new ModelAndView("app/stat/paperlist",modelMap);
	 }
	 /**
	  * 活性信息：文献列表
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/stat/paperlistthree.do")   
     public ModelAndView paperlistthree(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 String table = "CDC_ZF_BW_CF";
		 
		 String zufenlx = request.getParameter("zufenlx"); //组分类型
		 String zufenmc = request.getParameter("zufenmc"); //组分名称
		 String fenliff = request.getParameter("fenliff"); //分离方法
		 String chuhuaff = request.getParameter("chuhuaff");  // 纯化方法
		 String zufencdff = request.getParameter("zufencdff"); //组分测定方法
		 String zufenhl = request.getParameter("zufenhl"); //组分含量
		 
		 String dxcw = request.getParameter("dxcw");// 代谢产物
		 if(StringUtils.isNotEmpty(dxcw)){
			 table = "CDC_FJ_ZY_ZF_YLZY";
		 }

		 DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("SELECT title,author,PERIODICALNAME,b.id as pid FROM "+table+" a,CDC_BIBLIO b   where A.PID = b.id");
		 if(StringUtils.isNotEmpty(zufenlx)){
			 sql.append(" and zufenlx='").append(zufenlx).append("'");
		 }else if(StringUtils.isNotEmpty(zufenmc)){
			 sql.append(" and zufenmc='").append(zufenmc).append("'");
		 }else if(StringUtils.isNotEmpty(fenliff)){
			 sql.append(" and fenliff='").append(fenliff).append("'");
		 }else if(StringUtils.isNotEmpty(chuhuaff)){
			 sql.append(" and chuhuaff='").append(chuhuaff).append("'");
		 }else if(StringUtils.isNotEmpty(zufencdff)){
			 sql.append(" and zufencdff='").append(zufencdff).append("'");
		 }else if(StringUtils.isNotEmpty(zufenhl)){
			 sql.append(" and zufenhl='").append(zufenhl).append("'");
		 }
		 
		 List datalist = dbo.queryList(sql.toString(), null); 
		 modelMap.put("datalist", datalist);
		 return new ModelAndView("app/stat/paperlist",modelMap);
	 }
	 /**
	  * 安全信息：文献列表
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/stat/paperlistfour.do")   
     public ModelAndView paperlistfour(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 String bulfylx = request.getParameter("bulfylx"); //不良反应类型
		 String bulfybx = request.getParameter("bulfybx"); //不良反应表现
		 String zhiliaobz = request.getParameter("zhiliaobz"); //治疗病种
		 String buliangfyfl = request.getParameter("buliangfyfl");  // 不良反应分类
		 String buliangfyyy = request.getParameter("buliangfyyy"); //不良反应原因呢
		 
		 String table = "CDC_BLFY";
		 if(StringUtils.isNotEmpty(zhiliaobz) || StringUtils.isNotEmpty(buliangfyfl) || StringUtils.isNotEmpty(buliangfyyy)){
			 table = "CDC_BLFYBD";
		 }
		 
		 DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("SELECT   title,author,PERIODICALNAME,b.id as pid   FROM "+table+" a,CDC_BIBLIO b   where A.PID = b.id");
		 if(StringUtils.isNotEmpty(bulfylx)){
			 sql.append(" and bulfylx='").append(bulfylx).append("'");
		 }else if(StringUtils.isNotEmpty(bulfybx)){
			 sql.append(" and bulfybx='").append(bulfybx).append("'");
		 }else if(StringUtils.isNotEmpty(zhiliaobz)){
			 sql.append(" and zhiliaobz='").append(zhiliaobz).append("'");
		 }else if(StringUtils.isNotEmpty(buliangfyfl)){
			 sql.append(" and buliangfyfl='").append(buliangfyfl).append("'");
		 }else if(StringUtils.isNotEmpty(buliangfyyy)){
			 sql.append(" and BULIANGFYYY='").append(buliangfyyy).append("'");
		 }
		 logger.debug("sql:" + sql);
		 List datalist = dbo.queryList(sql.toString(), null); 
		 modelMap.put("datalist", datalist);
		 return new ModelAndView("app/stat/paperlist",modelMap);
	 }
	 
	 /**
	  * 临床统计： 研究医院
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/statlcYjyy.do")
	public ModelAndView hospitallist(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 String pidstr = request.getParameter("pidstr");
		 DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  YANJIUYY,count(*) as count FROM CDC_LINCHUANG   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by YANJIUYY) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
		 return new ModelAndView("app/stat/stat_lc_hospitallist",modelMap);
	}
	
	/**
	 * 临床统计： 治疗疾病
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/statlcZljb.do")
	public ModelAndView diseaselist(HttpServletRequest request,
			HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		 DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  ZHILJB,count(*) as count FROM CDC_LINCHUANG   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by ZHILJB) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
	 return new ModelAndView("app/stat/stat_lc_diseaselist",modelMap);
	}
	
	/**
	 * 临床统计： 诊断标准
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/statlcZdbz.do")
	public ModelAndView  criterialist(HttpServletRequest request,
			HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		 DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  ZDBZ,count(*) as count FROM CDC_LINCHUANG   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by ZDBZ) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
	 return new ModelAndView("app/stat/stat_lc_criterialist",modelMap);
	}
	
	/**
	 * 临床统计： 疗效标准
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/statlcLxbj.do")
	public ModelAndView curativelist(HttpServletRequest request,
			HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 String pidstr = request.getParameter("pidstr");
		 DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  LXBZ,count(*) as count FROM CDC_LINCHUANG   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by LXBZ) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
		 return new ModelAndView("app/stat/stat_lc_curativelist",modelMap);
	}
	
	/**
	 * 临床统计：对照组数
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/statlcDzzs.do")
	public ModelAndView grouplist(HttpServletRequest request,
			HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 String pidstr = request.getParameter("pidstr");
		 DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (select pid,(select title from CDC_BIBLIO where id=pid) as title,count(*) as count from CDC_LINCDZ    ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by pid) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
	 return new ModelAndView("app/stat/stat_lc_grouplist",modelMap);
	}
	
	/**
	 * 临床统计：疗效指标
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/statlcLxzb.do")
	public ModelAndView effectlist(HttpServletRequest request,
			HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		 DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (select pid,(select title from CDC_BIBLIO where id=pid) as title,count(*) as count from CDC_LXZB where rtype=2   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" and pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by pid) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
	 return new ModelAndView("app/stat/stat_lc_effectlist",modelMap);
	}
	 /************************************药理统计*************************************************************/
	 
	 /**
	  * 药理信息
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/stat/stattwo.do")   
     public void stattwo(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		//药理作用类型  药理作用    实验对象    实验对象类型  实验方法类型  实验方法名称  疗效指标
		 StringBuffer returnbuffer = new StringBuffer();
		 String pidstr = request.getParameter("pidstr");
 		 StringBuffer yaolizylx = new StringBuffer("SELECT distinct YLZYLX FROM CDC_FJ_ZY_ZF_YLZY WHERE 1=1  ");
 		 StringBuffer yaolizy = new StringBuffer("SELECT distinct YLZY FROM CDC_FJ_ZY_ZF_YLZY WHERE 1=1  ");
 		 StringBuffer shiyandx = new StringBuffer("SELECT distinct SYDX FROM CDC_SYQK WHERE 1=1  ");
 		 StringBuffer shiyandxlx = new StringBuffer("SELECT distinct SYDXLX FROM CDC_SYQK WHERE 1=1  ");
 		 StringBuffer shiyanfflx = new StringBuffer("SELECT distinct SYFFLX FROM CDC_JSFF WHERE 1=1  ");
 		 StringBuffer shiyanffmc = new StringBuffer("SELECT distinct SYFFMC  FROM CDC_JSFF WHERE 1=1  ");
 		 StringBuffer liaoxiaozb = new StringBuffer("SELECT count(*) FROM CDC_LXZB WHERE rtype=2  ");

		 if(StringUtils.isNotEmpty(pidstr)){
			 yaolizylx.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 yaolizy.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 shiyandx.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 shiyandxlx.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 shiyanfflx.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 shiyanffmc.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 liaoxiaozb.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
		 }
		 
		 DBMgr dbo = this.getDbo(request);
		 int ylzylx = dbo.queryCountForInt("select count(*) from ("+yaolizylx.toString()+")", null);
		 int ylzy = dbo.queryCountForInt("select count(*) from ("+yaolizy.toString()+")", null);
		 int sydx = dbo.queryCountForInt("select count(*) from ("+shiyandx.toString()+")", null);
		 int sydxlx = dbo.queryCountForInt("select count(*) from ("+shiyandxlx.toString()+")", null);
		 int syfflx = dbo.queryCountForInt("select count(*) from ("+shiyanffmc.toString()+")", null);
		 int syffmc = dbo.queryCountForInt("select count(*) from ("+liaoxiaozb.toString()+")", null);
		 int lxzb = dbo.queryCountForInt(liaoxiaozb.toString(), null);
		 
		 returnbuffer.append("m_2_1#").append(ylzylx).append(",");
		 returnbuffer.append("m_2_2#").append(ylzy).append(",");
		 returnbuffer.append("m_2_3#").append(sydx).append(",");
		 returnbuffer.append("m_2_4#").append(sydxlx).append(",");
		 returnbuffer.append("m_2_5#").append(syfflx).append(",");
		 returnbuffer.append("m_2_6#").append(syffmc).append(",");
		 returnbuffer.append("m_2_7#").append(lxzb);
		 PrintWriter out = response.getWriter();
	     out.print(returnbuffer.toString());
	     out.flush();
	     out.close();
	 }  
	 
	 /**
	  * 药理统计 ：药理作用类型
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/statylYlzylx.do")
	public ModelAndView yaolizylxlist(HttpServletRequest request,
			HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		 DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  YLZYLX,count(*) as count FROM CDC_FJ_ZY_ZF_YLZY   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by YLZYLX) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
		return new ModelAndView("app/stat/stat_yl_ylzylx",modelMap);
	}
	
	 /**
	  * 药理统计 ：药理作用
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/statylYlzy.do")
		public ModelAndView yaolizylist(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		 DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  YLZY,count(*) as count FROM CDC_FJ_ZY_ZF_YLZY   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by YLZY) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
		 return new ModelAndView("app/stat/stat_yl_ylzy",modelMap);
		}
	 
	/**
	 * 药理统计 ：实验对象
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/statylSydx.do")
	public ModelAndView sydxlist(HttpServletRequest request,
			HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  SYDX,count(*) as count FROM CDC_SYQK   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by SYDX) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
	 return new ModelAndView("app/stat/stat_yl_sydx",modelMap);
	}
	
	/**
	 * 药理统计 ：实验对象类型
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/statylSydxlx.do")
	public ModelAndView sydxlxlist(HttpServletRequest request,
			HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  SYDXLX,count(*) as count FROM CDC_SYQK   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by SYDXLX) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
	 return new ModelAndView("app/stat/stat_yl_sydxlx",modelMap);
	}
	
	/**
	 * 药理统计 ：实验方法类型
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/statylSyfflx.do")
	public ModelAndView syfflxlist(HttpServletRequest request,
			HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  SYFFLX,count(*) as count FROM CDC_JSFF   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by SYFFLX) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
	 return new ModelAndView("app/stat/stat_yl_syfflx",modelMap);
	}
	
	/**
	 * 药理统计 ：实验方法名称
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/statylSyffmc.do")
	public ModelAndView syffmclist(HttpServletRequest request,
			HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  SYFFMC,count(*) as count FROM CDC_JSFF   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by SYFFMC) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
	 return new ModelAndView("app/stat/stat_yl_syffmc",modelMap);
	}
	
	/**
	 * 药理统计 ：疗效指标
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/statylLxzb.do")
	public ModelAndView lxzblist(HttpServletRequest request,
			HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		 DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (select pid,(select title from CDC_BIBLIO where id=pid) as title,count(*) as count from CDC_LXZB where rtype=2   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" and pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by pid) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
		return new ModelAndView("app/stat/stat_yl_lxzb",modelMap);
	}
	 
	 
	 /*********************************************活性统计******************************************************/
	 
	 /**
	  * 活性信息
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/stat/statthree.do")   
     public void statthree(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 // 活性成分类型 活性成分名称 分离方法 提纯方法 活性成分测定方法 代谢产物名称 活性成分含量
		 StringBuffer returnbuffer = new StringBuffer();
		 String pidstr = request.getParameter("pidstr");
 		 StringBuffer huoxingcflx = new StringBuffer("SELECT distinct ZUFENLX FROM CDC_ZF_BW_CF WHERE 1=1  ");
 		 StringBuffer huoxingcfmc = new StringBuffer("SELECT distinct ZUFENMC FROM CDC_ZF_BW_CF WHERE 1=1  ");
 		 StringBuffer fenliff = new StringBuffer("SELECT distinct FENLIFF FROM CDC_ZF_BW_CF WHERE 1=1  ");
 		 StringBuffer tichunff = new StringBuffer("SELECT distinct CHUHUAFF FROM CDC_ZF_BW_CF WHERE 1=1  ");
 		 StringBuffer huoxingcfcdff = new StringBuffer("SELECT distinct ZUFENCDFF FROM CDC_ZF_BW_CF WHERE 1=1  ");
 		 StringBuffer daixiecwmc = new StringBuffer("SELECT distinct DXCW  FROM CDC_FJ_ZY_ZF_YLZY WHERE 1=1  ");
 		 StringBuffer huoxingcfhl = new StringBuffer("SELECT distinct ZUFENHL FROM CDC_ZF_BW_CF WHERE 1=1  ");

		 if(StringUtils.isNotEmpty(pidstr)){
			 huoxingcflx.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 huoxingcfmc.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 fenliff.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 tichunff.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 huoxingcfcdff.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 daixiecwmc.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 huoxingcfhl.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
		 }
		 
		 DBMgr dbo = this.getDbo(request);
		 int hxcflx = dbo.queryCountForInt("select count(*) from ("+huoxingcflx.toString()+")", null);
		 int hxcfmc = dbo.queryCountForInt("select count(*) from ("+huoxingcfmc.toString()+")", null);
		 int flff = dbo.queryCountForInt("select count(*) from ("+fenliff.toString()+")", null);
		 int tcff = dbo.queryCountForInt("select count(*) from ("+tichunff.toString()+")", null);
		 int hxcfcdff = dbo.queryCountForInt("select count(*) from ("+huoxingcfcdff.toString()+")", null);
		 int dxcwmc = dbo.queryCountForInt("select count(*) from ("+daixiecwmc.toString()+")", null);
		 int hxcfhl = dbo.queryCountForInt("select count(*) from ("+huoxingcfhl.toString()+")", null);
		 
		 returnbuffer.append("m_3_1#").append(hxcflx).append(",");
		 returnbuffer.append("m_3_2#").append(hxcfmc).append(",");
		 returnbuffer.append("m_3_3#").append(flff).append(",");
		 returnbuffer.append("m_3_4#").append(tcff).append(",");
		 returnbuffer.append("m_3_5#").append(hxcfcdff).append(",");
		 returnbuffer.append("m_3_6#").append(dxcwmc).append(",");
		 returnbuffer.append("m_3_7#").append(hxcfhl);
		 PrintWriter out = response.getWriter();
	     out.print(returnbuffer.toString());
	     out.flush();
	     out.close();
	 }
	 
	 /**
	  * 活性统计：活性成分类型
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/stathxHxcflx.do")
		public ModelAndView hxzflxlist(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  ZUFENLX,count(*) as count FROM CDC_ZF_BW_CF   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by ZUFENLX) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
			return new ModelAndView("app/stat/stat_hx_hxcflx",modelMap);
		}
	
	 /**
	  * 活性统计：活性成分名称
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/stathxHxcfmc.do")
		public ModelAndView hxzfmclist(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  ZUFENMC,count(*) as count FROM CDC_ZF_BW_CF   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by ZUFENMC) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
			return new ModelAndView("app/stat/stat_hx_hxcfmc",modelMap);
		}
	 
	 /**
	  * 活性统计：分离方法
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/stathxFlff.do")
		public ModelAndView flfflist(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  FENLIFF,count(*) as count FROM CDC_ZF_BW_CF   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by FENLIFF) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
			return new ModelAndView("app/stat/stat_hx_flff",modelMap);
		}
	
	 /**
	  * 活性统计：提纯方法
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/stathxTcff.do")
		public ModelAndView tcfflxlist(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  CHUHUAFF,count(*) as count FROM CDC_ZF_BW_CF   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by CHUHUAFF) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
			return new ModelAndView("app/stat/stat_hx_tcff",modelMap);
		}
	
	 /**
	  * 活性统计：活性成分测定方法
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/stathxHxcfcdff.do")
		public ModelAndView hxcfcdfflist(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  ZUFENCDFF,count(*) as count FROM CDC_ZF_BW_CF   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by ZUFENCDFF) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
			return new ModelAndView("app/stat/stat_hx_hxcfcdff",modelMap);
		}
	
	 /**
	  * 活性统计：代谢产物名称
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/stathxDxcw.do")
		public ModelAndView dxcwlist(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  DXCW,count(*) as count FROM CDC_FJ_ZY_ZF_YLZY   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by DXCW) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
			return new ModelAndView("app/stat/stat_hx_dxcw",modelMap);
		}
	
	 /**
	  * 活性统计：活性成分含量
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/stathxHxcfhl.do")
		public ModelAndView hxcfhllist(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		String pidstr = request.getParameter("pidstr");
		DBMgr dbo = this.getDbo(request);
		 StringBuffer sql = new StringBuffer("select * from (SELECT  ZUFENHL,count(*) as count FROM CDC_ZF_BW_CF   ");
		 if(StringUtils.isNotEmpty(pidstr)){
			 sql.append(" where pid in(").append(pidstr).append(")");
		 }
		 sql.append(" group by ZUFENHL) order by count desc");
		 List datalist = dbo.queryList(sql.toString(), null);
		 modelMap.put("pidstr", pidstr);
		 modelMap.put("datalist", datalist);
			return new ModelAndView("app/stat/stat_hx_hxcfhl",modelMap);
		}
	 
	 /*********************************************安全统计******************************************************/
	 
	 /**
	  * 安全信息
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/stat/statfour.do")
     public void statfour(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		//不良反应类型  不良反应表现  治疗病种  不良反应分类  不良反应产生原因
		 StringBuffer returnbuffer = new StringBuffer();
		 String pidstr = request.getParameter("pidstr");
 		 StringBuffer buliangfylx = new StringBuffer("SELECT distinct BULFYLX FROM CDC_BLFY WHERE 1=1  ");
 		 StringBuffer buliangfybx = new StringBuffer("SELECT distinct BULFYBX FROM CDC_BLFY WHERE 1=1  ");
 		 StringBuffer zhiliaobz = new StringBuffer("SELECT distinct ZHILIAOBZ FROM CDC_BLFYBD WHERE 1=1  ");
 		 StringBuffer buliangfyfl = new StringBuffer("SELECT distinct BULIANGFYFL FROM CDC_BLFYBD WHERE 1=1  ");
 		 StringBuffer buliangfycsyy = new StringBuffer("SELECT distinct BULIANGFYYY FROM CDC_BLFYBD WHERE 1=1  ");

		 if(StringUtils.isNotEmpty(pidstr)){
			 buliangfylx.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 buliangfybx.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 zhiliaobz.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 buliangfyfl.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
			 buliangfycsyy.append(" and pid in(select PID from CDC_PREHREB where ZYCYMC in(select TAGNAME from CDC_TAGS WHERE ID IN("+pidstr+")))");
		 }
		 
		 DBMgr dbo = this.getDbo(request);
		 int blfylx = dbo.queryCountForInt("select count(*) from ("+buliangfylx.toString()+")", null);
		 int blfybx = dbo.queryCountForInt("select count(*) from ("+buliangfybx.toString()+")", null);
		 int zlbz = dbo.queryCountForInt("select count(*) from ("+zhiliaobz.toString()+")", null);
		 int blfyfl = dbo.queryCountForInt("select count(*) from ("+buliangfyfl.toString()+")", null);
		 int blfycsyy = dbo.queryCountForInt("select count(*) from ("+buliangfycsyy.toString()+")", null);
		 
		 returnbuffer.append("m_4_1#").append(blfylx).append(",");
		 returnbuffer.append("m_4_2#").append(blfybx).append(",");
		 returnbuffer.append("m_4_3#").append(zlbz).append(",");
		 returnbuffer.append("m_4_4#").append(blfyfl).append(",");
		 returnbuffer.append("m_4_5#").append(blfycsyy);
		 PrintWriter out = response.getWriter();
	     out.print(returnbuffer.toString());
	     out.flush();
	     out.close();
	 }
	 
	 /**
	  * 安全统计：不良反应类型
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	 @RequestMapping(value="/stat/stataqBlfylx.do")
		public ModelAndView blfylxlist(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 String pidstr = request.getParameter("pidstr");
			DBMgr dbo = this.getDbo(request);
			 StringBuffer sql = new StringBuffer("select * from (SELECT  BULFYLX,count(*) as count FROM CDC_BLFY   ");
			 if(StringUtils.isNotEmpty(pidstr)){
				 sql.append(" where pid in(").append(pidstr).append(")");
			 }
			 sql.append(" group by BULFYLX) order by count desc");
			 List datalist = dbo.queryList(sql.toString(), null);
			 modelMap.put("pidstr", pidstr);
			 modelMap.put("datalist", datalist);
			return new ModelAndView("app/stat/stat_aq_blfylx",modelMap);
		}
	
	 /**
	  * 安全统计：不良反应表现
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/stataqBlfybx.do")
	public ModelAndView blfybxlist(HttpServletRequest request,
			HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 String pidstr = request.getParameter("pidstr");
			DBMgr dbo = this.getDbo(request);
			 StringBuffer sql = new StringBuffer("select * from (SELECT  BULFYBX,count(*) as count FROM CDC_BLFY   ");
			 if(StringUtils.isNotEmpty(pidstr)){
				 sql.append(" where pid in(").append(pidstr).append(")");
			 }
			 sql.append(" group by BULFYBX) order by count desc");
			 List datalist = dbo.queryList(sql.toString(), null);
			 modelMap.put("pidstr", pidstr);
			 modelMap.put("datalist", datalist);
		return new ModelAndView("app/stat/stat_aq_blffbx",modelMap);
	}
	
	 /**
	  * 安全统计：治疗病种
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/stataqZlbz.do")
	public ModelAndView zlbzlist(HttpServletRequest request,
			HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 String pidstr = request.getParameter("pidstr");
			DBMgr dbo = this.getDbo(request);
			 StringBuffer sql = new StringBuffer("select * from (SELECT  ZHILIAOBZ,count(*) as count FROM CDC_BLFYBD   ");
			 if(StringUtils.isNotEmpty(pidstr)){
				 sql.append(" where pid in(").append(pidstr).append(")");
			 }
			 sql.append(" group by ZHILIAOBZ) order by count desc");
			 List datalist = dbo.queryList(sql.toString(), null);
			 modelMap.put("pidstr", pidstr);
			 modelMap.put("datalist", datalist);
		return new ModelAndView("app/stat/stat_aq_zlbz",modelMap);
	}
	 /**
	  * 安全统计：不良反应分类
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/stataqBlfyfl.do")
		public ModelAndView blfyfllist(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 String pidstr = request.getParameter("pidstr");
			DBMgr dbo = this.getDbo(request);
			 StringBuffer sql = new StringBuffer("select * from (SELECT  BULIANGFYFL,count(*) as count FROM CDC_BLFYBD   ");
			 if(StringUtils.isNotEmpty(pidstr)){
				 sql.append(" where pid in(").append(pidstr).append(")");
			 }
			 sql.append(" group by BULIANGFYFL) order by count desc");
			 List datalist = dbo.queryList(sql.toString(), null);
			 modelMap.put("pidstr", pidstr);
			 modelMap.put("datalist", datalist);
			return new ModelAndView("app/stat/stat_aq_blfyfl",modelMap);
		}
	
	/**
	  * 安全统计：不良反应产生原因
	 * @param request
	 * @param response
	 * @param modelMap
	 * @return
	 * @throws ServletException
	 * @throws IOException
	 */
	@RequestMapping(value="/stat/stataqBlfycsyy.do")
		public ModelAndView blffcsyylist(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 String pidstr = request.getParameter("pidstr");
			DBMgr dbo = this.getDbo(request);
			 StringBuffer sql = new StringBuffer("select * from (SELECT  BULIANGFYYY,count(*) as count FROM CDC_BLFYBD   ");
			 if(StringUtils.isNotEmpty(pidstr)){
				 sql.append(" where pid in(").append(pidstr).append(")");
			 }
			 sql.append(" group by BULIANGFYYY) order by count desc");
			 List datalist = dbo.queryList(sql.toString(), null);
			 modelMap.put("pidstr", pidstr);
			 modelMap.put("datalist", datalist);
			return new ModelAndView("app/stat/stat_aq_blfycsyy",modelMap);
		}
}
